package com.cmower.dzone.optional;

import java.util.Optional;
import java.util.function.Predicate;

public class FilterOptionalDemo {
    public static void main(String[] args) {
        String password = "12345";
        Optional<String> opt = Optional.ofNullable(password);
        System.out.println(opt.filter(pwd -> pwd.length() > 6).isPresent());



Predicate<String> len6 = pwd -> pwd.length() > 6;
Predicate<String> len8 = pwd -> pwd.length() < 10;

password = "1234567";
opt = Optional.ofNullable(password);
boolean result = opt.filter(len6.and(len8)).isPresent();
System.out.println(result);
    }
}
